package seatiger.tomcat.catalina.startup;

import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSetBase;
import seatiger.tomcat.catalina.Container;
import seatiger.tomcat.catalina.Logger;
import seatiger.tomcat.catalina.core.StandardEngine;


/**
 * Engin解析规则
 */
public class EngineRuleSet extends RuleSetBase {

    protected String prefix = null;

    public EngineRuleSet(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public void addRuleInstances(Digester digester) {
        digester.addObjectCreate(prefix + "Engine", StandardEngine.class);
        digester.addSetProperties(prefix + "Engine");
        digester.addSetNext(prefix + "Engine","setContainer", Container.class.getName());
        //添加日志记录器
        digester.addObjectCreate(prefix + "Engine/Logger",null,"className");
        digester.addSetProperties(prefix + "Engine/Logger");
        digester.addSetNext(prefix + "Engine/Logger","setLogger", Logger.class.getName());
    }
}
